package cn.bigfire.wedesk.service.bo;

import cn.bigfire.wedesk.bean.Wedesk;
import cn.bigfire.wedesk.net.protocol.Protocol;
import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.Date;

public class CustInfo {

    Context context;//自带context
    Wedesk.LoginReq loginReq = new Wedesk.LoginReq();//登陆时客户端参数信息
    UserEntity userEntity = new UserEntity();//登录成功后,用户基本信息 db数据
    Date loginTime = new Date();//登录时间

    public CustInfo(Context context) {
        this.context = context;
    }

    //managers  根据场景需要，加载用户数据到内存

    public void send(Protocol protocol) {
        if (protocol.getCmd() == 0) {
            protocol.setCmd(context.getCmd());
        }
        context.getChannel().writeAndFlush(protocol);
    }

    @Override
    public String toString() {
        return JSON.toJSONString(userEntity);
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public Wedesk.LoginReq getLoginReq() {
        return loginReq;
    }

    public void setLoginReq(Wedesk.LoginReq loginReq) {
        this.loginReq = loginReq;
    }

    public UserEntity getUserEntity() {
        return userEntity;
    }

    public void setUserEntity(UserEntity userEntity) {
        this.userEntity = userEntity;
    }

    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }
}
